package com.zhou.allocation;


import com.zhou.utils.token.JwtInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 一只小海猪
 * * @date 2022/8/4
 */

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    /**
     * 添加jwt拦截器，并指定拦截路径
     * */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/code")
                .excludePathPatterns("/admin/login/**")
                //swagger3相关路径 knife4j版本3.0.3  springfox3.0.0
                .excludePathPatterns("/swagger-ui.html","/webjars/**","/v3/api-docs","/swagger-resources/**","/doc.html")

                .excludePathPatterns("/userInfo/login");
    }

    /**
     * jwt拦截器
     * */
    @Bean
    public JwtInterceptor jwtInterceptor() {
        return new JwtInterceptor();
    }
}

